package mips.instructions.fpu;

import mips.instructions.Instruction;

/**
 * <code>CFC1</code> instruction<br/>
 * Move Control From Coprocessor 1</br>
 * @author jnmartin84@gmail.com
 */
public class CFC1 extends Instruction {

	private static CFC1 INSTANCE = new CFC1();
	private static final String INSTRUCTION_NAME = "CFC1";

	private CFC1(){}

	public static final CFC1 getInstance() {
		return INSTANCE;
	}

	/**
	 * <b>Format:</b><br/>
	 * CFCz rt, rd<br/><br/>
	 * <b>Description:</b><br/>
	 * The contents of coprocessor control register rd of coprocessor unit z are<br/>
	 * loaded into general register rt.<br/><br/>
	 * This instruction is not valid for CP0.<br/>
	 * <b>Operation:</b><br/>
	 * T: data &larr; CCR[z,rd]<br/>
	 * T+1: GPR[rt] &larr; data
	 */
	@Override
	public final void execute(final int instruction) {
		
		RT = (instruction >> 16) & 0x0000001F;
		RD = (instruction >> 11) & 0x0000001F; // FS 
		
		mips.R4300i.GPR[RT] = (int) mips.COP1.CONTROL[RD];
		
		mips.R4300i.PC = mips.R4300i.nPC;
		mips.R4300i.nPC = mips.R4300i.PC + 4;
	}
	
	public final String emit(final int instruction) {
		return	"";
	}
	
	public final String getName(final int instruction) {
		return getName();
	}
	
	public final String getName() {
		return INSTRUCTION_NAME;
	}
}